# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :create_app.py
# @Time      :2022/6/8 0008 19:27
# @Author    :何胜利
from flask import Flask
from flask_cors import CORS

from common.utils.jwt_auth import jwt_authentication
from models import db
from views.user import user_bp


def create_flask_app(config):
    app = Flask(__name__)
    app.config.from_object(config)
    db.init_app(app)
    CORS(app)

    app.register_blueprint(user_bp)
    app.before_request(jwt_authentication)

    return app
